class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users, :force => true do |t|
      t.references :user_info, :null => true
      t.string  :email,    :limit => 50, :null => false
      t.decimal :discount, :precision => 4, :scale => 2, :null => true, :default => "0.00"

      t.string :crypted_password,        :null => true #due to OpenId
      t.string :password_salt,           :null => true
      t.string :persistence_token,       :null => true
      t.string :perishable_token,        :null => true

      t.integer  :login_count,        :limit => 5,:null => true, :default => 0
      t.integer  :failed_login_count, :limit => 3,:null => true, :default => 0
      t.datetime :last_request_at
      t.datetime :current_login_at
      t.datetime :last_login_at
      t.datetime :last_request_at
      t.string   :current_login_ip,   :limit => 20
      t.string   :last_login_ip,      :limit => 20

      t.timestamps
    end

    add_index :users, :email, :unique => true
    add_index :users, :persistence_token
  end
end
